from rest_framework.serializers import ModelSerializer

from .models import *  # 导入模型层所有数据

from rest_framework import serializers
#    就是一个包                      普通序列化器

class ShopSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model=Shop
        fields='__all__'

class ShopkeepSer(ModelSerializer):
    # 自定义表名
    class Meta():
        # 嵌套序列化器
        Shopser=ShopSer()
        model=Shopkeeper
        fields='__all__'





# 课程表序列化器
class CouserSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model = Couser
        fields = '__all__'

# 班级序列化器
class ClassSer(ModelSerializer):
    # 嵌套序列化器  把课程序列化器套进去 加只读 加获取多个
    couser=CouserSer(read_only=True,many=True)
    # 自定义表名
    class Meta():
        model=Class
        fields='__all__'

# 课程表序列化器
class StudentSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model = Student
        fields = '__all__'

class ShowStuSer(ModelSerializer):
    cla=ClassSer()
    # 自定义表名
    class Meta():
        model = Student
        fields = '__all__'

# 分类表序列化器
class CateSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model = Cate
        fields = '__all__'

# 商品表序列化器
class Show_ShopSer(ModelSerializer):
    #嵌套序列化器 把分类表序列化器套进去 加只读 加获取多个
    # cate=CateSer()
    # 自定义表名
    class Meta():
        model = Show_Shop
        fields = '__all__'

# 用户表序列化器
class UserSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model = User
        fields = '__all__'

# 用户表序列化器
class TeacherSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model = Teacher
        fields = '__all__'

# 新建商品表序列化器
class XShopSer(ModelSerializer):
    # 自定义表名
    class Meta():
        model = XShop
        fields = '__all__'

